{% extends "approval/base.html" %}
{% block title %} 申请详情-{{ object.code }} {% endblock %}
{% block content %}
    <div class="col-lg-6 col-lg-offset-3">
        <section class="panel panel-default">
            <div class="panel-heading">
                <h3 class="panel-title">申请详情-{{ object.code }}</h3>
            </div>
            <div class="panel-body" style="padding: 10px;">
                <form class="form-horizontal" method="post" action="{% url 'approval:application_submit' object.pk %}?s={{ request.GET.s }}&t={{ request.GET.t }}&g={{ request.GET.g }}&search={{ request.GET.search }}&page={{ request.GET.page }}"
                      enctype="multipart/form-data">
                    {% csrf_token %}
                    <input type="hidden" name="status" id="id_status" value="{% if object.status == 1 %}2{% elif object.status == 4 %}6{% endif %}">
                    <div class="form-group">
                        <div class="col-lg-2 col-md-2 col-xs-4">申请人：</div>
                        <div class="col-lg-10 col-md-10 col-xs-8"> {{ object.created_by.full_name }} </div>
                    </div>
                    <div class="form-group">
                        <div class="col-lg-2 col-md-2 col-xs-4">日期：</div>
                        <div class="col-lg-10 col-md-10 col-xs-8"> {{ object.date_info }} </div>
                    </div>
                    <div class="form-group">
                        <div class="col-lg-2 col-md-2 col-xs-4">内容：</div>
                        <div class="col-lg-10 col-md-10 col-xs-8"> {{ object.name }} </div>
                    </div>
                    <div class="form-group">
                        <div class="col-lg-2 col-md-2 col-xs-4">备注：</div>
                        <div class="col-lg-10 col-md-10 col-xs-8"> {{ object.initial_notes|linebreaks }} </div>
                    </div>
                    <div class="form-group">
                        <div class="col-lg-2 col-md-2 col-xs-4">项目：</div>
                        <div class="col-lg-10 col-md-10 col-xs-8"> {{ object.related_project }} </div>
                    </div>
                    <div class="form-group">
                        <div class="col-lg-2 col-md-2 col-xs-4">状态：</div>
                        <div class="col-lg-10 col-md-10 col-xs-8"> {{ object.get_status_display }} </div>
                    </div>
                    <div class="form-group">
                        <div class="col-lg-2 col-md-2 col-xs-4">金额：</div>
                        <div class="col-lg-10 col-md-10 col-xs-8">
                            申请 {{ object.initial_amount }} 元
                        </div>
                    </div>
                    <div class="form-group">
                        <div class="col-lg-2 col-md-2 col-xs-4">发票：</div>
                        <div class="col-lg-10 col-md-10 col-xs-8"> {{ object.has_invoice|yesno:"有,无" }} </div>
                    </div>
                    {% if object.status == 4 or object.status == 6 %}
                    <div class="form-group">
                        <div class="col-lg-2 col-md-2 col-xs-4">打款方式：</div>
                        <div class="col-lg-10 col-md-10 col-xs-8"> {{ object.get_pay_channel_display }} </div>
                    </div>
                    {% endif %}
                    <div class="form-group">
                        <div class="col-lg-2 col-md-2 col-xs-4">附件：</div>
                        <div class="col-lg-10 col-md-10 col-xs-8">
                            {% for attachment in object.attachments %}
                                <a href="{{ attachment.file.url }}">{{ attachment.file_name }}</a>
                                {% if not forloop.last %}<br>{% endif %}
                            {% endfor %}
                        </div>
                    </div>
                    {% if object.status > 3 %}
                    <div class="well">
                        <div class="form-group">
                            <div class="col-lg-2 col-md-2 col-xs-4">审批金额：</div>
                            <div class="col-lg-10 col-md-10 col-xs-8"> {{ object.approval_amount }} 元</div>
                        </div>
                        <div class="form-group">
                            <div class="col-lg-2 col-md-2 col-xs-4">审批备注：</div>
                            <div class="col-lg-10 col-md-10 col-xs-8"> {{ object.approval_notes|default_if_none:'无' }} </div>
                        </div>
                    </div>
                    {% endif %}
                    <div class="form-group">
                        <div class="col-lg-12 text-right">
                            {% if object.status == 1 or object.status == 5 %}<a href="{% url 'approval:application_change' object.pk  %}?s={{ request.GET.s }}&t={{ request.GET.t }}&g={{ request.GET.g }}&search={{ request.GET.search }}&page={{ request.GET.page }}"><span class="btn btn-info">编辑</span></a>{% endif %}
                            {% if object.status == 1 %}<button type="submit" class="btn btn-primary">提交</button>{% endif %}
                            {% if object.status == 4 %}<button type="submit" class="btn btn-primary">确认收款</button>{% endif %}
                            {% if object.status == 2 and request.GET.g|escape == '2' %}<a href="{% url 'approval:application_approve' object.pk %}?s={{ request.GET.s }}&t={{ request.GET.t }}&g={{ request.GET.g }}&search={{ request.GET.search }}&page={{ request.GET.page }}"><span class="btn btn-primary">审批</span></a>{% endif %}
                            <a href="{% url 'approval:applications' %}?s={{ request.GET.s }}&t={{ request.GET.t }}&g={{ request.GET.g }}&search={{ request.GET.search }}&page={{ request.GET.page }}"><span class="btn btn-danger">返回</span></a>
                        </div>
                    </div>
                </form>
            </div>
        </section>
    </div>
{% endblock %}